//
//  StatisticsSelectAddressBtnView.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2021/6/23.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "StatisticsSelectAddressBtnView.h"

@interface StatisticsSelectAddressBtnView ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIImageView *arrowImgView;
@property (nonatomic, strong) UIButton *btn;

@end

@implementation StatisticsSelectAddressBtnView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = Color_backgroundColor;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        self.bgView.backgroundColor = Color_backgroundColor;
        self.bgView.layer.masksToBounds = YES;
        self.bgView.layer.cornerRadius = 6;
        self.bgView.layer.borderColor = HexColor(0x707070).CGColor;
        self.bgView.layer.borderWidth = 1;
        [self addSubview:self.bgView];
        
        self.arrowImgView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width - 10 - 13, (frame.size.height - 6) * 0.5, 13, 6)];
        self.arrowImgView.image = [UIImage imageNamed:@"statistics_bottom_arrow"];
        [self.bgView addSubview:self.arrowImgView];
        
        self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(10, (frame.size.height - 14) * 0.5, self.arrowImgView.nim_left - 10 - 10, 14)];
        self.titleLab.font = [UIFont systemFontOfSize:13];
        self.titleLab.textColor = HexColor(0x333333);
        [self.bgView addSubview:self.titleLab];
        
        self.btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        [self.btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.btn];
    }
    return self;
}

- (void)btnClick {
    if (self.clickBlock) {
        self.clickBlock();
    }
}

-(void)setTitleStr:(NSString *)titleStr {
    _titleStr = titleStr;
    self.titleLab.text = titleStr;
}

@end
